﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Algorithm.Easy_933_RecentCounter
{
    class MainProject
    {
        static void Main(string[] args)
        {
            //Console.WriteLine(SubArrayRanges(new int[] { 4, -2, -3, 4, 1 }));
            Console.ReadKey();
        }
    }
    public class RecentCounter
    {
        Queue<int> m_Que = new Queue<int>();

        public RecentCounter()
        {

        }

        public int Ping(int t)
        {
            #region 优化
            m_Que.Enqueue(t);
            while (m_Que.Peek()<t-3000) m_Que.Dequeue();
            return m_Que.Count;
            #endregion

            #region 自己做的
            //m_Que.Enqueue(t);
            //int preVaue = t - 3000;
            //int num = 0;
            //foreach (var item in m_Que)
            //{
            //    if (item>= preVaue)
            //    {
            //        num++;
            //    }
            //}
            //return num;
            #endregion
        }
    }
}
